﻿@using ChatGpt.Shared.Module
@using BlazorComponent.I18n
@namespace ChatGpt.Shared
@inject StorageJsInterop StorageJsInterop
@inject I18n I18n

<MList>
    <MSubheader>@I18n.T("Dialogues.Title")</MSubheader>
    @foreach (var item in DialoguesModules)
    {
        <MListItem Link @onclick="async ()=> await OnClick.InvokeAsync(item)">
            <MListItemContent>
                <MListItemTitle>
                    @item.Title
                    <MIcon OnClick="async ()=>await OnClose(item)" Style="float:right;">mdi-close</MIcon>
                </MListItemTitle>
            </MListItemContent>
        </MListItem>
    }

    <MListItem>
        <MListItemContent>
            @*当点击新增显示输入框，输入框离开焦点显示新增按钮*@
            @if (!_show)
            {
                <MButton Block OnClick="OnCreate" Text>@I18n.T("Dialogues.Add.Label")</MButton>
            }
            else
            {
                <MTextField @ref="_textField" @bind-Value="newDialoguesModule.Title"
                            Solo Style="max-height: 36px" OnBlur="CreateDialogues">
                </MTextField>
            }
        </MListItemContent>
    </MListItem>
</MList>